package com.itbaizhan.service.impl;

import com.itbaizhan.common.MyMessage;
import com.itbaizhan.service.IMessageProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.stereotype.Service;

/**
 * @author spf
 * @date 2024/2/18
 * @time 19:21
 */
@Service
public class MessageProviderImpl implements IMessageProvider {

    @Autowired
    private StreamBridge streamBridge;

    @Override
    public String send(String message) {
        MyMessage myMessage = new MyMessage();
        myMessage.setPayload(message);

        streamBridge.send("myBroadcast-out-0", myMessage);
        return "SUCCESS";
    }

    @Override
    public String sendGroup(String message) {
        MyMessage myMessage = new MyMessage();
        myMessage.setPayload(message);

        streamBridge.send("myGroup-out-0", myMessage);
        return "SUCCESS";
    }
}
